const Goods = require('../model/goods.model')


class GoodsService {
  async createGoods(goods) {
    const res = await Goods.create(goods)
    return res.dataValues
  }

  async updateGoods(goods) {
    const { id, ...goodRes } = goods
    const res = await Goods.update(goodRes, {
      where: {
        id: id
      }
    })
    return res[0] > 0 ? true : false
  }

  async removeGoods(id) {
    const res = await Goods.destroy({
      where: {
        id: id
      }
    })
    return res > 0 ? true : false
  }
}

module.exports = new GoodsService();